package com.intellagric.controller.module.ift_scene;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.IftSceneType;
import com.intellagric.service.iftmonitor.ift_scene.SceneTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/10/25
 * @DESC： 场景类型信息管理
 */
@Controller
public class SceneTypeController {

    @Autowired
    private SceneTypeService sceneTypeService;

    /**
     * 添加场景类型信息
     * @Param sceneType
     * @return ResponseMessage
     */
    @RequestMapping("/scene/type/add")
    @ResponseBody
    public ResponseMessage add(IftSceneType sceneType) {
        //初始参数
        sceneType.setId(UUID.randomUUID().toString().replaceAll("-",""));
        sceneType.setCreateDate(new Date());
        sceneType.setUpdateDate(new Date());
        return sceneTypeService.addSceneType(sceneType);
    }


    /**
     * 删除场景类型信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/scene/type/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return sceneTypeService.deleteSceneType(id);
    }

    /**
     * 修改场景类型信息
     * @Param sceneType
     * @return ResponseMessage
     */
    @RequestMapping("/scene/type/edit")
    @ResponseBody
    public ResponseMessage edit(IftSceneType sceneType) {
        return sceneTypeService.editSceneType(sceneType);
    }

    /**
     * 查询场景类型信息
     * @return IftSceneType
     */
    @RequestMapping("/scene/type/{id}")
    @ResponseBody
    public IftSceneType get(@PathVariable String id) {
        return sceneTypeService.getSceneTypeById(id);
    }

    /**
     * 查询场景类型树信息
     * @return LayuiDataGridResult
     */
    @RequestMapping("/scene/type/tree")
    @ResponseBody
    public LayuiDataGridResult getTree() {
        return sceneTypeService.getSceneTypeTree();
    }

    /**
     * 查询场景类型树信息
     * @return LayuiDataGridResult
     */
    @RequestMapping("/scene/type/tree/select")
    @ResponseBody
    public List<IftSceneType> getTreeSelect() {
        return sceneTypeService.getSceneTypeTree().getData();
    }

    /**
     * 查询场景类型信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/scene/type/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return sceneTypeService.getSceneTypeList();
    }

}
